package 蓝桥真题;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class 跳跃 {
	   static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	   final static int N=110,M=100010;
	   static int g[][]=new int[N][M],dix[]={0,0,0,1,2,3,1,1,2},diy[]={1,2,3,0,0,0,1,2,1},n,m;
	   static long res=-0x3f3f3f3f;
	   static void scan()throws Exception{
		      String[]ss=br.readLine().split(" ");
		      n=Integer.parseInt(ss[0]);m=Integer.parseInt(ss[1]);
		      for(int i=0;i<n;i++){
		    	  ss=br.readLine().split(" ");
		    	  for(int j=0;j<m;j++)
		    		  g[i][j]=Integer.parseInt(ss[j]);
		      }
	   }
	   static void dfs(int x,int y,int s){
		      if(x==n-1&&y==m-1){
		    	  res=Math.max(res,s);
		    	  return;
		      }
		      for(int i=0;i<9;i++){
		    	  int u=x+dix[i],k=y+diy[i];
		    	  if(u>=0&&u<n&&k>=0&&k<m){
		    		  dfs(u,k,s+g[u][k]);
		    	  }
		      }
	   }
       public static void main(String[]args)throws Exception{
    	      scan();
    	      dfs(0,0,g[0][0]);
    	      System.out.print(res);
       }
}
